import router from './router'

const whiteList = ['/login'] // no redirect whitelist
import {verify} from '@/api/user'
router.beforeEach(async(to, from, next) => {
    
    //放行login
    var token = localStorage.getItem("token");
     if (to.path === '/login') {
        next()
     }else{
       //校验令牌
       verify().then(res=>{
          if(res.code == 0 ){//合法令牌
             next()
          }else{
            next({ path: '/login' })
          }
       })
     }
})

router.afterEach(() => {
  
})
